package bb.lanxing.util;

import android.content.Context;

import java.util.Calendar;

import bb.lanxing.R;
import bb.lanxing.model.database.RouteBook;
import bb.lanxing.model.database.Workout;

public class LushuTitleUtil {
    public static String buildDefaultTitlePrefix(RouteBook routeBook) {
        String format = DateUtil.format(routeBook.getCreateTime(), 1);
        Calendar calendar = Calendar.getInstance();
        calendar.setTimeInMillis(routeBook.getCreateTime());
        int i = calendar.get(11);
        if (i < 6) {
            return format + " 凌晨 ";
        } else if (i < 12) {
            return format + " 上午 ";
        } else if (i < 18) {
            return format + " 下午 ";
        } else {
            return format + " 晚上 ";
        }
    }

    public static String buildDefaultTitleType(Context context, RouteBook routeBook) {
        int sport = routeBook.getSport();
        if (sport == Workout.TYPE_WALKING) {
            return context.getResources().getString(R.string.walking);
        } else if (sport == Workout.TYPE_RUNNING) {
            return context.getResources().getString(R.string.running);
        } else if (sport == Workout.TYPE_CYCLING) {
            return context.getResources().getString(R.string.cycling);
        } else {
            return context.getResources().getString(R.string.other_sport);
        }
    }

    public static String buildLushuDefaultTitle(Context context, RouteBook routeBook) {
        String buildDefaultTitlePrefix = buildDefaultTitlePrefix(routeBook);
        String buildDefaultTitleType = buildDefaultTitleType(context, routeBook);
        return buildDefaultTitlePrefix + buildDefaultTitleType;
    }
}